import { flatten } from '@angular/compiler';
import { Component, Input, OnInit } from '@angular/core';
import {ModalConfig} from "@src/app/model/jack.model";

@Component({
  selector: 'jack-modal',
  templateUrl: './modal.component.html',
  styleUrls: ['./modal.component.css']
})
export class ModalComponent implements OnInit {
  @Input() conf: ModalConfig;

  constructor() { }

  ui = {
    show: false,
  }

  ngOnInit(): void {
  }

  public onclose():void {
    if(!this.conf) {
      return;
    }
    this.ui.show = false
    this.conf.onclose &&  this.conf.onclose()

  }
  public onopen():void {
    if(!this.conf) {
      return;
    }
    this.conf.onopen&&  this.conf.onopen()
  }

  public open():void{
    this.ui.show = true;
  }

  public confirm():void {
    if(!this.conf) {
      return;
    }
    // this.conf.onconfirm && this.conf.onconfirm()
    
  }

  public close():void {
    this.ui.show = false;
  }

}
